//
//import android.content.ContentResolver;
//import android.content.ContentValues;
//import android.content.Context;
//import android.database.Cursor;
//import android.net.Uri;
//import android.util.Log;
//
//import java.util.ArrayList;
//import java.util.List;
//
////新增apk 安装管理名单
////1. 禁止安装包名单为空时，所有app均可安装，不为空时，仅名单内app可安装
////2. 禁止卸载包名单为指定不可卸载app
//public class PackageUtil {
//    private static PackageUtil appListHelper;
//    private static final Uri INSTALL_APP_WHITELIST_URI = Uri.parse("content://com.android.packageinstaller.app.provider/install_app_whitelist");
//    private static final Uri UNINSTALL_APP_BLACKLIST_URI = Uri.parse("content://com.android.packageinstaller.app.provider/uninstall_app_blacklist");
//
//    //adb 执行test操作
//    //查询
//    //adb shell content query --uri content://com.android.packageinstaller.app.provider/install_app_whitelist
//    //删除
//    //adb shell content delete --uri content://com.android.packageinstaller.app.provider/install_app_whitelist //条件删除 --where "pkg_name='pkg_name'"
//    //新增
//    //adb shell content insert --uri content://com.android.packageinstaller.app.provider/install_app_whitelist  --bind pkg_name:s:com.pkg.name
//
//    public static PackageUtil getInstance() {
//        if (appListHelper == null) {
//            appListHelper = new PackageUtil();
//        }
//        return appListHelper;
//    }
//
//    //新增可安装白名单
//    public void addInstallPackage(Context context, String pgk) {
//        ContentResolver contentResolver = context.getContentResolver();
//        ContentValues newValues = new ContentValues();
//        newValues.put("pkg_name", pgk);
//        contentResolver.insert(INSTALL_APP_WHITELIST_URI, newValues);
//    }
//
//    //移除可安装白名单
//    public void removeInstallPackages(Context context, String pgk) {
//        ContentResolver contentResolver = context.getContentResolver();
//        contentResolver.delete(INSTALL_APP_WHITELIST_URI, "pkg_name = ?", new String[]{pgk});
//    }
//
//    //新增禁止卸载名单
//    public void addUnInstallPackage(Context context, String pgk) {
//        ContentResolver contentResolver = context.getContentResolver();
//        ContentValues newValues = new ContentValues();
//        newValues.put("pkg_name", pgk);
//        contentResolver.insert(UNINSTALL_APP_BLACKLIST_URI, newValues);
//
//    }
//
//    //移除禁止卸载名单
//    public void removeUnInstallPackages(Context context, String pgk) {
//        ContentResolver contentResolver = context.getContentResolver();
//        contentResolver.delete(UNINSTALL_APP_BLACKLIST_URI, "pkg_name = ?", new String[]{pgk});
//    }
//
//    //获取禁止卸载名单
//    public List<String> getUnInstallPackages(Context context) {
//        ContentResolver contentResolver = context.getContentResolver();
//        Cursor c = contentResolver.query(UNINSTALL_APP_BLACKLIST_URI, null, null, null, null);
//        List<String> l = new ArrayList<>();
//        if (c.getCount() != 0) {
//            while (c.moveToNext()) {
//                int index = c.getColumnIndex("pkg_name");
//                String pkgname = c.getString(index);
//                l.add(pkgname);
//                Log.i("TAG", "isInstallerEnable c.moveToNext() " + pkgname);
//            }
//        }
//        return l;
//    }
//
//    //获取可以安装名单
//    public List<String> getInstallPackages(Context context) {
//        ContentResolver contentResolver = context.getContentResolver();
//        Cursor c = contentResolver.query(INSTALL_APP_WHITELIST_URI, null, null, null, null);
//        List<String> l = new ArrayList<>();
//        if (c.getCount() != 0) {
//            while (c.moveToNext()) {
//                int index = c.getColumnIndex("pkg_name");
//                String pkgname = c.getString(index);
//                l.add(pkgname);
//                Log.i("TAG", "isInstallerEnable c.moveToNext() " + pkgname);
//            }
//        }
//        return l;
//    }
//
//}
//
//